package com.skyline.search.server;

import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
import com.skyline.search.config.Config;
import com.skyline.search.index.IndexProxy;
import com.skyline.search.index.impl.IndexProxyImpl;
import com.skyline.search.search.SearchProxy;
import com.skyline.search.search.impl.SearchProxyImpl;

/**
 * Class <code>SkylineSearchServer</code> 提供IndexProxy和SearchProxy的rmi调用
 * 
 * @author Jairus Chan
 * @version 0.1, 11/30/10
 * @since JDK1.6
 */

public class SkylineSearchServer {

	public SkylineSearchServer() {
		try {

			// 配置系统
			Config config = Config.getConfig();
			// 注册端口号为1012
			LocateRegistry.createRegistry(10140);

			// 注册Indexer
			IndexProxy indexproxy = new IndexProxyImpl(config);
			Naming.rebind("rmi://localhost:10140/indexproxy", indexproxy);

			// 注册Searcher
			SearchProxy searchproxy = new SearchProxyImpl(config);
			Naming.rebind("rmi://localhost:10140/searchproxy", searchproxy);
			
			// 输出"服务器启动 成功!"
			System.out.println("Server ia already started!");
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	public static void main(String args[]) {
		new SkylineSearchServer();
	}
}